namespace SumerCoreDevOps.Shared.Constants;

/// <summary>
/// TCP 协议常量
/// </summary>
public static class TcpProtocolConstants
{
    /// <summary>
    /// 魔术头 (0x5343 = "SC" for SumerCore)
    /// </summary>
    public const ushort MagicHeader = 0x5343;

    /// <summary>
    /// 当前协议版本
    /// </summary>
    public const byte ProtocolVersion = 0x01;

    /// <summary>
    /// 最大消息长度 (10MB)
    /// </summary>
    public const int MaxMessageLength = 10 * 1024 * 1024;

    /// <summary>
    /// 消息头长度（魔术头2字节 + 版本1字节 + 消息类型1字节 + 压缩标志1字节 + 数据长度4字节）
    /// </summary>
    public const int MessageHeaderLength = 9;

    /// <summary>
    /// CRC32校验码长度
    /// </summary>
    public const int CRC32Length = 4;

    /// <summary>
    /// 完整消息头+尾长度
    /// </summary>
    public const int MessageOverheadLength = MessageHeaderLength + CRC32Length;

    /// <summary>
    /// 心跳间隔（秒）
    /// </summary>
    public const int HeartbeatIntervalSeconds = 30;

    /// <summary>
    /// 心跳超时（秒）
    /// </summary>
    public const int HeartbeatTimeoutSeconds = 90;

    /// <summary>
    /// 重连间隔（秒）
    /// </summary>
    public const int ReconnectIntervalSeconds = 10;

    /// <summary>
    /// 最大重连次数
    /// </summary>
    public const int MaxReconnectAttempts = 5;

    /// <summary>
    /// 临时凭证默认有效期（分钟）
    /// </summary>
    public const int TempCredentialValidMinutes = 10;

    /// <summary>
    /// AES 密钥长度
    /// </summary>
    public const int AesKeyLength = 16; // AES-128
}
